package sms

import (
	. "Go-Easy/pkg/config"
	"github.com/qiniu/go-sdk/v7/auth"
	"github.com/qiniu/go-sdk/v7/sms"
)

//七牛云短信发送方法
func SMS_Send(Mobiles []string, Parameters map[string]interface{}) (string, error) {
	var (
		AccessKey = SMS.AccessKey // 替换成自己 Qiniu 账号的 AccessKey.
		SecretKey = SMS.SecretKey // 替换成自己 Qiniu 账号的 SecretKey.
	)
	mac := auth.New(AccessKey, SecretKey)
	manager := sms.NewManager(mac)

	req := sms.MessagesRequest{
		SignatureID: SMS.SignatureID,
		TemplateID:  SMS.TemplateID,
		Mobiles:     Mobiles,
		Parameters:  Parameters,
	}
	ret, err := manager.SendMessage(req)
	if err != nil {
		return "", err
	}
	return ret.JobID, nil
}
